home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Utilities / Converters / Convert_MacPaint / Source / shared.subproj / common.h < prev    next >
Text File  |  1995-06-12  |  7KB  |  206 lines

  1. /***********************************************************************
  2. Common header code for Convert programs
  3. Copyright (C) 1993 David John Burrowes
  4.  
  5. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version.
  6.  
  7. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
  8.  
  9. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  10.  
  11. The author, David John Burrowes, can be reached at:
  12.     davidjohn@kira.net.netcom.com
  13.     David John Burrowes
  14.     1926 Ivy #10
  15.     San Mateo, CA 94403-1367
  16. ***********************************************************************/
  17.  
  18. /*
  19. ====================================================================
  20. This file declares several data types that varoious applications may wish to use.
  21.     This is $Revision: 1.3 $ of this file
  22.     It was last modified by $Author: death $ on $Date: 93/04/04 23:45:35 $
  23. Note that this file was created while using the New Century Schoolbook Roman typeface.  You may find that some things line up strangely if you don't use that family.
  24. $Log:    common.h,v $
  25.  * Revision 1.3  93/04/04  23:45:35  death
  26.  * Sun Apr  4 23:45:34 PDT 1993
  27.  * 
  28.  * Revision 1.2  93/01/10  15:09:00  death
  29.  * Sun Jan 10 15:09:00 PST 1993
  30.  * 
  31.  * Revision 1.1  92/07/26  13:57:07  death
  32.  * Initial revision
  33.  * 
  34.  * Revision 1.1  92/02/09  18:41:40  death
  35.  * Initial revision
  36.  * 
  37. ====================================================================
  38. */
  39.  
  40. //
  41. //    92.11.08        djb        Added NSmajor and NSMinor flags, since there don't seem to
  42. //                        be any in the NS headers (probably I'm not looking in the
  43. //                        right place).  This isn't the right place for them, but...
  44. //
  45. #define    NSmajor        3
  46. #define    NSminor        0
  47.  
  48. #define    DoNS3DragNDrop 1
  49.  
  50. #import <objc/objc.h>
  51.  
  52. //
  53. //    Draft 1 of standard types.  I can see this is a small step towards making everything an
  54. //    object. But, we'll see how we like what we have.  I'm a bit bothered by Cstring, for now,
  55. //    but...
  56. //
  57. //     Integer should be the largest available signed intergral number on the system.
  58. //    It is capitalized and fully spelled to help distnguish from normal int's in C.
  59. //    Naturally, PositiveInteger is it's unsigned counterpart.  Note that PositiveInteger,
  60. //    despite it's name, does include 0! =)
  61. //
  62. typedef     long int    Integer;
  63. typedef    unsigned long int    PositiveInteger;
  64. //
  65. //    92.06.21 djb    added 'Real' type.
  66. //
  67. typedef    double    Real;
  68. //
  69. //    Character is used to represent a letter, digit, or symbol on the local system.  It makes no
  70. //    pretenses at being able to deal with an ideographic, or potentially even a sylabic writing
  71. //    system.  In general, it should not be used as a number  (C's char type is a signed thing, so
  72. //    CString, below, does NOT refer to an array of Character. =(  )
  73. //
  74. typedef    unsigned char    Character;
  75. //
  76. //    Cstring is a special case, since one just ends up using pointers to chars frequently.
  77. //    roCString is a read only cstring.  I could have made rocstring as char const *, but
  78. //    it seemed more appropriate to make the name refer to read-only (constant) data,
  79. //    rather than pointer.
  80. //    How about fixedCString for those that are char const *??
  81. //
  82. typedef    char*    CString;
  83. typedef    const char*    roCString;
  84. //
  85. //    id is all well and good, but let's be a bit more general and readable.  So, we define
  86. //    Instance to be a reference to an object
  87. //    NOTE: Seems I can't call it Object bcause there is already a class called Object (oops).
  88. //    Naming it thus Instance.  Since id/object/instance is the default type in Objective C,
  89. //    one really won't need to use the name all that often.
  90. //
  91. typedef     id    Instance;
  92. //
  93. //    Pointer is a reference to an untyped pointer.
  94. //
  95. typedef    void*    Pointer;
  96. //
  97. //    Boolean is, of course, a type for storing true or false values.  no others (undefined, etc)
  98. //
  99. typedef    BOOL    Boolean;
  100. //
  101. //    GenericType is used to store any of the preceeding types.
  102. //
  103. typedef union
  104. {
  105.     Integer        integer;
  106.     PositiveInteger    positiveinteger;
  107.     Character    character;
  108.     CString        cstring;
  109.     Instance        instance;
  110.     Pointer        pointer;
  111.     Boolean        boolean;
  112. }
  113. GenericType;
  114. //
  115. //    DataType is used to store any of the primary data types here, like GenericType, but
  116. //    also to record which type is stored, and thus allow for some type checking by the
  117. //    programmer.
  118. //
  119. typedef struct
  120. {
  121.     GenericType    data;
  122.     Integer        type;
  123. }
  124. DataType;
  125. //
  126. //    Now, define some values that correspond to thse types...
  127. //
  128. //    (Ahh, for C++'s ability to define constants...)
  129. //
  130. #define    CARRIAGERETURN        0x0D
  131. #define    LINEFEED                0x0A
  132. #define    NEWLINE                0x0A
  133. #define    TAB                        0x09
  134. //#define    NULL                    0x00    /* already defined, I believe */
  135. #define    ESCAPE                    0x1B
  136. #define    NullCharacter            0x00
  137. //
  138. //    Cstring definitions
  139. //
  140. #define    NullCString    ((CString) 0x00)
  141. #define    EndOfCString    ((char) 0x00)
  142. //
  143. //    Object definitions
  144. //    (nil is defined as part of Objective c.  note the case! Nil is a nil Class structure).
  145. //
  146. #define    NullInstance    ((Instance) nil)
  147. //
  148. //    Pointer definitions
  149. //
  150. #define    NullPointer    0x00
  151. //
  152. //    Boolean definitions.
  153. //
  154. //#define    YES        /* Defined by Objective C.  uncomment if this changes or this moves*/
  155. //#define    NO        /* Defined by Objective C.  uncomment if this changes or this moves*/
  156. #define    True    YES
  157. #define    False    NO
  158. //
  159. //    Define constants for use in the DataType struct
  160. //
  161. #define    TYPE_NONE                0
  162. #define    TYPE_INTEGER            1
  163. #define    TYPE_POSITIVEINTEGER    2
  164. #define    TYPE_CHARACTER        3
  165. #define    TYPE_CSTRING            4
  166. #define    TYPE_INSTANCE        5
  167. #define    TYPE_POINTER            6
  168. #define    TYPE_BOOLEAN            7
  169.  
  170. //
  171. //    Define some types. 
  172. //    These can all be considered as special cases of PositiveInteger, below.
  173. //    92.08.02    Added signed versions, for those cases where one needs specific sized
  174. //            signed integers.
  175. //
  176. typedef    unsigned char        Byte;
  177. typedef    char                SignedByte;
  178. typedef    unsigned char        bits8;
  179. typedef    char                Signed8Bits;
  180. typedef    unsigned short int    bits16;
  181. typedef    short int                Signed16Bits;
  182. typedef    unsigned int            bits32;
  183. typedef     int                    Signed32Bits;
  184. typedef    Byte*                ByteString;
  185. typedef    const Byte*            ConstByteString;
  186. typedef    Integer                ErrorCode;
  187.  
  188. #define    NullByteString    ((ByteString) 0x00)
  189.  
  190. //    92.05.25    djb    Added a ConstCString.  The name is misleading in that it suggests the
  191. //    data, not the pointer, is constant.  But, its what comes to mind first, andI'm using this
  192. //    far and away more frequently than any other const construct...
  193. //
  194. typedef    char const *    ConstCString;
  195.  
  196. //
  197. //    Prototypes
  198. //
  199. Boolean    EvenUnsignedNum (PositiveInteger);
  200. CString    NewCString(PositiveInteger);
  201. void    FreeCString(CString theString);
  202. ByteString    NewByteString(PositiveInteger);
  203. void    FreeByteString(ByteString theString);
  204. Pointer    NewPointer(PositiveInteger length);
  205. void    FreePointer(Pointer thePointer);
  206.